-- AmazonAgent
-- Created by chengb Feb/17/2016
-- 亚马逊代理

module("AmazonAgent", package.seeall);

-- 初始化
function init()
end

-- 显示登录窗口
function showAmazonLogin()
    callJavaFunc("showChannelLogin", {}, "()V");
end

-- 登出
function logout()
end

----------------------
-- 购买商品
-- @param sku 商品库存标识
function buyPurchase(sku)
    local serverId = getCurrentServerId();
    local account  = getGaming3rdAccount();
    local platform = PUBLISH_TYPE_AMAZON;

    callJavaFunc("buyPurchase", {sku, account, serverId, platform},
        "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
end

-- 显示成就列表
function displayAmazonAchievements()
    callJavaFunc("displayAmazonAchievements", {}, "()V");
end

-------------------------
-- 更新成就进度
-- @param achievementId     亚马逊后台配置的成就编号
-- @param completePercent   完成度
function incrementAmazonAchievement(achievementId, completePercent)
    callJavaFunc("incrementAmazonAchievement", {achievementId, completePercent}, "(Ljava/lang/String;F)V");
end

-- 显示排行榜列表
function displayAllAmazonLeaderboards()
    callJavaFunc("displayAllAmazonLeaderboards", {}, "()V");
end

-----------------
-- 显示排行榜
-- @param leaderboardId Amazon后台配置的排行榜编号
function displayAmazonLeaderboard(leaderboardId)
    callJavaFunc("displayAmazonLeaderboard", {leaderboardId}, "(Ljava/lang/String;)V");
end

-------------------------
-- 提交排行榜积分
-- @param leaderboardId   后台配置的排行榜编号
-- @param score           需要提交的分数
function submitAmazonLeaderboardScore(leaderboardId, score)
    trace("AmazonAgent", "leaderboardId = %s, score = %d", leaderboardId, score);
    callJavaFunc("submitAmazonLeaderboardScore", {leaderboardId, score}, "(Ljava/lang/String;I)V");
end



